package com.ai.dmc.index.web.control.impl;

import com.ai.common.xml.util.ControlConstants.RETURN_CODE;
import com.ai.frame.bean.InputObject;
import com.ai.frame.bean.OutputObject;
import com.ai.frame.logger.Logger;
import com.ai.frame.logger.LoggerFactory;
import com.ai.dmc.index.web.control.IControlService;

public class ControlServiceImpl implements IControlService {
	private com.ai.frame.IControlService dmcControlService;
	private static final Logger logger = LoggerFactory
			.getApplicationLog(ControlServiceImpl.class);

	public OutputObject execute(InputObject inputObject) {
		OutputObject outputObject = null;
		try {
			long start = System.currentTimeMillis();
			logger.info("START INVOKE WEBAPP...", "");

			// 调用WebApp服务
			outputObject = dmcControlService.execute(inputObject);
			
			long end = System.currentTimeMillis();
			logger.info("END INVOKE WEBAPP...", String.valueOf(end - start) + "ms");
		} catch (Exception e) {
			logger.error("Error:", "调用后台服务异常", e);
			outputObject = new OutputObject();
			outputObject.setReturnCode(RETURN_CODE.SYSTEM_ERROR);
			outputObject.setReturnMessage(e.getMessage() == null ? e.getCause().getMessage() : e.getMessage());
		}
		return outputObject;
	}

	public com.ai.frame.IControlService getDmcControlService() {
		return dmcControlService;
	}

	public void setDmcControlService(com.ai.frame.IControlService dmcControlService) {
		this.dmcControlService = dmcControlService;
	}

}
